package com.hetao.register;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by hetao on 2018/3/12.
 */
public class Beanfactory {
    private static Map<String,Object> map=new ConcurrentHashMap<String, Object>();

    public static Object getInstance(String className){
        if(map.containsKey(className)){
            return map.get(className);
        }else{
            Object obj= null;
            try {
                obj = Class.forName(className);
                map.put(className,obj);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            return obj;
        }
    }
}
